Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
strip-indent
Advanced tools
The strip-indent npm package is used to remove the leading whitespace from every line in a given text block. This is particularly useful when working with multi-line strings that need to be displayed without indentation or when processing template literals in JavaScript that should not retain the formatting of the source code.
Strip indentation from a multi-line string
This feature allows you to remove the common leading whitespace from all lines in a text block, making it easier to handle formatted multi-line strings without unwanted indentation.
const stripIndent = require('strip-indent');
const text = ` line one
line two
line three`;
console.log(stripIndent(text));
Dedent is similar to strip-indent but also trims the trailing newline. It is often used in template literals to avoid first-line indentation and to ensure that the output does not end with a newline, making it slightly different in its approach compared to strip-indent.
While strip-indent removes indentation, indent-string adds indentation to each line in a string. This package can be considered the opposite of strip-indent. It allows specifying the number of spaces or the type of indentation (spaces or tabs), offering more flexibility depending on the user's needs.
Strip leading whitespace from every line in a string
The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove.
Useful for removing redundant indentation.
$ npm install --save strip-indent
$ bower install --save strip-indent
$ component install sindresorhus/strip-indent
var str = '\tunicorn\n\t\tcake';
/*
unicorn
cake
*/
stripIndent('\tunicorn\n\t\tcake');
/*
unicorn
cake
*/
$ npm install --global strip-indent
$ strip-indent --help
Usage
$ strip-indent <file>
$ echo <string> | strip-indent
Example
$ echo '\tunicorn\n\t\tcake' | strip-indent
unicorn
cake
FAQs
Strip leading whitespace from each line in a string
The npm package strip-indent receives a total of 18,749,340 weekly downloads. As such, strip-indent popularity was classified as popular.
We found that strip-indent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.